public class test {

    public static int find(int[] arr){
        int flag = 0;
        int i = 0, j = 0;
        for(i = 0;i < arr.length - 1;i++){
            flag = 0;
            for(j = 0;j < arr.length;j++){
                if(i == j){
                    continue;
                }
                if(arr[i] == arr[j]){
                    flag = 1;
                }
            }
            if(flag == 0){
                flag = arr[i];
                break;
            }
        }
        return flag;
    }
    //只出现一次的数字
    public static void main1(String[] args) {
        int[] arr = {1,1,2,3,3,4,4};
        int ret = find(arr);
        System.out.println(ret);
    }

    //多数元素
    public static int best(int[] arr){
        int count = 0;
        int target = 0;
        for(int i = 0;i<arr.length;i++){
            int tmp = 0;
            for(int j = 0;j<arr.length;j++){
                if (i == j){
                    continue;
                }
                if(arr[i] == arr[j]){
                    tmp++;
                }
            }
            if(tmp > count){
                count = tmp;
                target = arr[i];
            }
        }
        return target;
    }

    public static void main2(String[] args) {
        int[] arr = new int[]{1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,4,5};
        int ret = best(arr);
        System.out.println(ret);
    }


    //存在连续三个奇数的数组
    public static boolean check(int[] arr){
        int count = 0;
        for(int i = 0;i< arr.length;i++)
        {
            if(arr[i] % 2 != 0){
                count++;
                if(count == 3){
                    return true;
                }
            }
            else{
                count = 0;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6,7,7,7};
        boolean ret = check(arr);
        System.out.println(ret);
    }
}
